// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'

import App from './App'
import router from './router'
import fastClick from 'fastclick'
import 'babel-polyfill'
import axios from './config/axios'
import store from './store'
import 'styles/common.css'

import './config/appback'
import VideoPlayer from 'vue-video-player'
import {Tab, Tabs, Form, Field, Swipe, SwipeItem, Checkbox, CheckboxGroup, Button,Divider, Uploader, Toast,Overlay,Loading,List,Skeleton,Lazyload,Sticky,Search,Icon,NavBar} from 'vant';

import { Tabbar, TabbarItem } from 'vant';

import 'vant/lib/index.css';

Vue.use(Uploader);
Vue.use(Overlay);
Vue.use(Loading);
Vue.use(List);
Vue.use(VideoPlayer);
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Button);
Vue.use(Divider);
Vue.use(Skeleton);
Vue.use(Lazyload, {
    lazyComponent: true,
    loading:"../addons/tb_toupiao/template/static/images/mobile/index/loading.gif",
    preload:'200px',
  });
Vue.use(Sticky);
Vue.use(Search);
Vue.use(Icon);
Vue.use(NavBar);

Vue.use(Tabbar);
Vue.use(TabbarItem);
Vue.use(Swipe);
Vue.use(SwipeItem);
Vue.use(Form);
Vue.use(Field);


import 'video.js/dist/video-js.css'
import "vue-video-player/src/custom-theme.css";

import './assets/less/theme.less';


//加载占位
// import VueOccupy from 'vue-occupy'
// Vue.use(VueOccupy)

// import { Lazyload,Toast } from 'mint-ui';
// import 'mint-ui/lib/style.css'
//懒加载
// Vue.use(Lazyload);

Vue.prototype.$toast = Toast

// import { WechatPlugin, XHeader, Tabbar, TabbarItem, LoadingPlugin, Swiper, SwiperItem, Icon, PopupPicker, Group, Cell, CellBox, XInput } from 'vux'
import { WechatPlugin, XHeader, LoadingPlugin, Swiper, SwiperItem, PopupPicker, Group, Cell, CellBox, XInput} from 'vux'


// Vue.component('icon', Icon)

Vue.use(WechatPlugin); //支持jssdk 

import VueScroller from 'vue-scroller'
Vue.use(VueScroller)

//卡片
Vue.component('group', Group)
Vue.component('cell', Cell)
Vue.component('cell-box', CellBox)
//select 选择
Vue.component('popup-picker', PopupPicker)

Vue.component('x-header', XHeader); //支持头部导航
Vue.component('x-input', XInput); //支持输入框
//底部导航
// Vue.component('tabbar', Tabbar)
// Vue.component('tabbar-item', TabbarItem)

Vue.use(LoadingPlugin) //加载图标

//图片轮播
Vue.component('swiper', Swiper)
Vue.component('swiper-item', SwiperItem)

Vue.prototype.$axios = axios

//引入jssdk配置
import { wxShare } from "./config/wxshare";
Vue.prototype.$wxShare = wxShare

//解决ios输入框需要长按或则双击才能调起键盘问题
const str = navigator.userAgent.toLowerCase()
const ver = str.match(/cpu iphone os (.*?) like mac os/)

if (!ver) {//非IOS系统
    // 引入fastclick 做相关处理
    fastClick.attach(document.body);
}
else {
    if (parseInt(ver[1]) < 11) {
        // 引入fastclick 做相关处理
        fastClick.attach(document.body);
    }
    

}

Vue.config.productionTip = false

console.log(window.location.href);




function GetRequest() {  
    var url = location.search; //获取url中"?"符后的字串  
    var theRequest = new Object();  
    if (url.indexOf("?") != -1) {  
       var str = url.substr(1);  
       var strs = str.split("&");  
       for(var i = 0; i < strs.length; i ++) {  
          theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
       }  
    }  
    return theRequest;  
 }
 function delParam(paramKey) {
    var url = window.location.href;    //页面url
    var urlParam = window.location.search.substr(1);   //页面参数
    var beforeUrl = url.substr(0, url.indexOf("?"));   //页面主地址（参数之前地址）
    var nextUrl = "";

    var arr = new Array();
    if (urlParam != "") {
        var urlParamArr = urlParam.split("&"); //将参数按照&符分成数组
        for (var i = 0; i < urlParamArr.length; i++) {
            var paramArr = urlParamArr[i].split("="); //将参数键，值拆开
            //如果键雨要删除的不一致，则加入到参数中
            if (paramArr[0] != paramKey) {
                arr.push(urlParamArr[i]);
            }
        }
    }
    if (arr.length > 0) {
        nextUrl = "?" + arr.join("&");
    }
    url = beforeUrl + nextUrl;
    return url;
}

//如果有参数则 直接跳转到参数页面
// http://cstec.mcnvp.com:8080/?&sr=%2Fscore%2Findex
this.query_data = GetRequest();
console.log(this.query_data);
console.log(852);
console.log(typeof(this.query_data.sr)=='undefined');
if(typeof(this.query_data.sr)!= 'undefined'&&this.query_data.sr!='' ){
    var ur = delParam('sr');
    // console.log(ur);
    // console.log(12489234);
    // console.log(window.location.href.split('#')[0]);
// this.$router.push({path: this.query_data});
// this.$router.push({path:window.location.href.split('?')[0]+'#/'+this.query_data.sr})
window.location.href = ur+'#'+this.query_data.sr;
}


/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    store,
    components: { App },
    template: '<App/>'
})